{% macro summary_line(kind, covered, total, precision) %}
{%- set per = percent(num=covered, den=total) -%}
<div class="level-item has-text-centered">
  <div>
    <p class="heading">{{ kind | capitalize }}</p>
    <p class="title has-text-{{ per | severity(kind=kind) }}">
      <abbr title="{{ covered }} / {{ total }}">{{ per | round(precision=precision) }} %</abbr></p>
  </div>
</div>
{% endmacro -%}

{% macro summary(parents, stats, precision) %}
<nav class="breadcrumb is-right" aria-label="breadcrumbs">
  <ul>
    {%- for parent in parents -%}
    <li><a href="{{ parent.0 | safe }}">{{ parent.1 }}</a></li>
    {%- endfor -%}
    <li class="is-active"><a href="#">{{ current }}</a></li>
  </ul>
</nav>
<nav class="level">
  {{ self::summary_line(kind="lines", covered=stats.covered_lines, total=stats.total_lines, precision=precision) }}
  {{ self::summary_line(kind="functions", covered=stats.covered_funs, total=stats.total_funs, precision=precision) }}
  {% if branch_enabled %}
  {{ self::summary_line(kind="branches", covered=stats.covered_branches, total=stats.total_branches, precision=precision) }}
  {% endif %}
</nav>
{% endmacro %}

{% macro stats_line(name, url, stats, precision) %}
{%- set lines_per = percent(num=stats.covered_lines, den=stats.total_lines) -%}
{%- set lines_sev = lines_per | severity(kind="lines") -%}
{%- set functions_per = percent(num=stats.covered_funs, den=stats.total_funs) -%}
{%- set functions_sev = functions_per | severity(kind="functions") -%}
{% if branch_enabled %}
{%- set branches_per = percent(num=stats.covered_branches, den=stats.total_branches) -%}
{%- set branches_sev = branches_per | severity(kind="branches") -%}
{% endif %}
<tr>
  <th><a href="{{ url }}">{{ name }}</a></th>
  <!-- -->
  <td class="p-2">
    <progress
      class="progress is-{{ lines_sev }} is-large"
      value="{{ lines_per }}"
      max="100">
      {{ lines_per | round(precision=precision) }}%
    </progress>
  </td>
  <td class="has-text-centered has-background-{{ lines_sev }} p-2">
    {{ lines_per | round(precision=precision) }}%
  </td>
  <td class="has-text-centered has-background-{{ lines_sev }} p-2">
    {{ stats.covered_lines }} / {{ stats.total_lines }}
  </td>
  <!-- -->
  <td class="has-text-centered has-background-{{ functions_sev }} p-2">{{ functions_per | round(precision=precision) }}%</td>
  <td class="has-text-centered has-background-{{ functions_sev }} p-2">{{ stats.covered_funs }} / {{ stats.total_funs }} </td>
  <!-- -->
  {% if branch_enabled %}
  <td class="has-text-centered has-background-{{ branches_sev }} p-2">{{ branches_per | round(precision=precision) }}%</td>
  <td class="has-text-centered has-background-{{ branches_sev }} p-2">{{ stats.covered_branches }} / {{ stats.total_branches }}</td>
  {% endif %}
</tr>
{% endmacro %}
